<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="#(ctx_path)/plugins/layui/css/layui.css">
</head>
<body style="background-color:#4E5465;">

	<div style="height: 110px">&nbsp;</div>

	
	<div class="layui-row layui-col-space5" style="margin-left: auto;margin-right: auto;">
		<div class="layui-col-md3">
			&nbsp;
		</div>
		<div class="layui-col-md4">
			<form class="layui-form" action="">

				<div class="layui-form-item">
					<div class="layui-input-block" align="center" style="font-size: 18px;color: white;">
						<b>104j.com</b><br/>
						后台管理系统
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<input type="text" name="loginName" lay-verify="loginName" autocomplete="off" placeholder="登录名" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<input type="password" name="password" lay-verify="password" autocomplete="off" placeholder="密码" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<input type="text" name="captchaCode" lay-verify="captchaCode" autocomplete="off" placeholder="验证码" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<img src="#(ctx_path)/captcha" id="captchaImg" onclick="changeCaptcha();">
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" type="button" onclick="doLogin();" style="width: 100%;">登录</button>
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block" align="center" style="color: white;">
						<a href="javascript:alert('请联系管理员');">忘记密码？</a>
					</div>
				</div>
				
			</form>
			
		</div>
		<div class="layui-col-md4">
			<div class="layui-col-md12">
				&nbsp;
			</div>
		</div>
	</div>

<script src="#(ctx_path)/plugins/layui/layui.js"></script>
<script src="#(ctx_path)/plugins/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="#(ctx_path)/plugins/jquery/1.11.3/jquery.min.js"></script>
<script>

	layui.use(['element','table','layer','tree','laytpl'], function() {
		
		
	});


	function changeCaptcha(){
		$("#captchaImg").attr("src","#(ctx_path)/captcha?t="+new Date().getTime());
	}
	
  	function doLogin(){
  		
  		var loginName=$(":input[name='loginName']").val();
  		var password=$(":input[name='password']").val();
  		
  		if(loginName==""){
  			layer.open({
				type : 1,
				content : '<div style="padding: 20px 100px;">请输入用户名</div>',
				btn : '确认',
				btnAlign : 'c',
				shade : 0.5,
				yes : function() {
					layer.closeAll();
				}
			});
  			return;
  		}
  		
  		if(password==""){
  			layer.open({
				type : 1,
				content : '<div style="padding: 20px 100px;">请输入密码</div>',
				btn : '确认',
				btnAlign : 'c',
				shade : 0.5,
				yes : function() {
					layer.closeAll();
				}
			});
  			return;
  		}
  		
	  	$.ajax({
		  type:'get',
		  url:'#(ctx_path)/admin/login/action',
		  data:$("form").serialize(),
		  success:function(data){
			  if(data.code=="0"){
				  window.location.href='#(ctx_path)/admin';
			  }else{
				  
				  var text="账号或密码错误！";
				  if(data.code=="3"){
					  text="验证码错误！";
				  }
				  
				  layer.open({
						type : 1,
						content : '<div style="padding: 20px 100px;">'+text+'</div>',
						btn : '确认',
						btnAlign : 'c',
						shade : 0.5,
						yes : function() {
							layer.closeAll();
						}
					});
					changeCaptcha();
				}
	
			}
		});
	}
</script>
</body>
</html>
